/**
 * @author 雷明浩
 * @date 2025/5/29 16:11
 */
public class InvertTree {
    // leetcode 翻转二叉树
    // https://leetcode.cn/problems/invert-binary-tree/?envType=study-plan-v2&envId=top-100-liked
    public TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return root;
        }
        invertTree(root.left);
        invertTree(root.right);
        TreeNode tmp = root.left;
        root.left = root.right;
        root.right = tmp;
        return root;
    }
}